package com.hub.netty.client.config;

import com.hub.netty.base.domain.Message;
import io.netty.channel.Channel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class NettyClientBoot {

    private final NettyChannelPool nettyChannelPool;

    public void sendMsg(Message message) {
        Channel channel = nettyChannelPool.borrowChannel();
        channel.writeAndFlush(message);
        nettyChannelPool.returnChannel(channel);
    }
}
